import numpy as np
import matplotlib.pyplot as plt

# 定义三个 3D 向量
vector1 = np.array([1, 2, 3])


# 设置图片清晰度
plt.rcParams["figure.dpi"] = 300

# 创建一个 3D 图形窗口
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")

# 绘制第一个向量
ax.quiver(0, 0, 0, vector1[0], vector1[1], vector1[2], color="r", label="Vector 1")


# 设置坐标轴范围
max_val = max(5, 5, 5) + 1
ax.set_xlim([0, max_val])
ax.set_ylim([0, max_val])
ax.set_zlim([0, max_val])

# 添加坐标轴标签和标题
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
ax.set_title("3D Vector Addition")

# 显示图例
ax.legend()

# 显示图形
plt.show()
